import Joi from 'joi'

export const gameValidation = {
  // 创建游戏验证
  createGame: {
    body: Joi.object({
      roomId: Joi.string().required(),
      gameType: Joi.string().required(),
      config: Joi.object({
        minBet: Joi.number().min(1).required(),
        maxBet: Joi.number().min(1).required(),
        duration: Joi.number().min(30).max(300).required(),
      }).required(),
    }),
  },

  // 下注验证
  placeBet: {
    body: Joi.object({
      gameId: Joi.string().required(),
      amount: Joi.number().min(1).required(),
      target: Joi.string().required(),
    }),
  },

  // 获取游戏列表验证
  getGames: {
    query: Joi.object({
      roomId: Joi.string(),
      status: Joi.string(),
      page: Joi.number().min(1),
      size: Joi.number().min(1).max(100),
    }),
  },

  // 获取游戏详情验证
  getGameById: {
    params: Joi.object({
      gameId: Joi.string().required(),
    }),
  },

  // 获取游戏结果验证
  getGameResult: {
    params: Joi.object({
      gameId: Joi.string().required(),
    }),
  },

  // 获取游戏记录验证
  getGameRecords: {
    query: Joi.object({
      startDate: Joi.string().pattern(/^\d{4}-\d{2}-\d{2}$/),
      endDate: Joi.string().pattern(/^\d{4}-\d{2}-\d{2}$/),
      type: Joi.string(),
      page: Joi.number().min(1),
      size: Joi.number().min(1).max(100),
    }),
  },

  // 获取游戏统计验证
  getGameStats: {
    query: Joi.object({
      startDate: Joi.string().pattern(/^\d{4}-\d{2}-\d{2}$/),
      endDate: Joi.string().pattern(/^\d{4}-\d{2}-\d{2}$/),
    }),
  },

  // 获取排行榜验证
  getGameRankings: {
    query: Joi.object({
      type: Joi.string().valid('daily', 'weekly', 'monthly', 'total'),
    }),
  },
}
